package core;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import javax.imageio.ImageIO;

import Common.ImageValidator;

public class searchEngine {

	/* TO DO */
	public static ArrayList<BufferedImage> getSimilarImages(BufferedImage img, File file)
	{
		ArrayList<BufferedImage> l = new ArrayList<BufferedImage>();
		BufferedImage image = null;

		for (File f : file.listFiles()) {
			if (ImageValidator.validate(f.getName())) {
				try {
					image = ImageIO.read(f);
//					System.out.println("NAMES : "+f.getName());
					l.add(image);
					image.flush();
					image = null;
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}

		return l;
	}
	
	public static int getSelectedImageIndex(String name) 
	{
		if (name.equals("im1.png")) {
			return 0;
		}
		else if (name.equals("im10.png")) {
			return 1;
		}
		else if (name.equals("im11.png")) {
			return 2;
		}
		else if (name.equals("im12.png")) {
			return 3;
		}
		else if (name.equals("im13.png")) {
			return 4;
		}
		else if (name.equals("im14.png")) {
			return 5;
		}
		else if (name.equals("im15.png")) {
			return 6;
		}
		else if (name.equals("im16.png")) {
			return 7;
		}
		else if (name.equals("im17.png")) {
			return 8;
		}
		else if (name.equals("im18.png")) {
			return 9;
		}
		else if (name.equals("im19.png")) {
			return 10;
		}
		else if (name.equals("im2.png")) {
			return 11;
		}
		else if (name.equals("im21.png")) {
			return 12;
		}
		else if (name.equals("im22.png")) {
			return 13;
		}
		else if (name.equals("im23.png")) {
			return 14;
		}
		else if (name.equals("im24.png")) {
			return 15;
		}
		else if (name.equals("im25.png")) {
			return 16;
		}
		else if (name.equals("im26.png")) {
			return 17;
		}
		else if (name.equals("im27.png")) {
			return 18;
		}
		else if (name.equals("im3.png")) {
			return 19;
		}
		else if (name.equals("im4.png")) {
			return 20;
		}
		else if (name.equals("im5.png")) {
			return 21;
		}
		else if (name.equals("im6.png")) {
			return 22;
		}
		else if (name.equals("im7.png")) {
			return 23;
		}
		else if (name.equals("im8.png")) {
			return 24;
		}
		else if (name.equals("im9.png")) {
			return 25;
		}
		return -1;
	}
}
